package com.itheima.springbootmybatistest.dao;

import com.itheima.springbootmybatistest.domain.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Description:
 * @Version: V1.0
 */
@Mapper
@Repository
public interface UserDao {

    @Select("select * from t_user")
    List<User> findAll();

    @Insert("insert into t_user (username,password) values (#{username},#{password})")
    void add(User user);

    @Delete("delete from t_user where id = #{id}")
    void deleteById(Integer id);


    @Update("update t_user set username = #{username},password = #{password} where id = #{id}")
    void update(User user);

    @Select("select * from t_user where id = #{id}")
    User findById(Integer id);
}
